import requests
from bs4 import BeautifulSoup

# 发送请求,获取疫情首页数据响应对象
response = requests.get('https://ncov.dxy.cn/ncovh5/view/pneumonia')
home_page = response.content.decode()
# print(home_page)

# 通过 ctrl+f 在交互端查找"美国"
# 美国数据在标签里:<script id="getListByCountryTypeService2true">
# 使用BeautifulSoup提取疫情数据
soup = BeautifulSoup(home_page, "lxml")
script = soup.find(id='getListByCountryTypeService2true')
text1 = script.string
print(text1)